package com.sdkx.app.dialog;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.Window;

import com.sdkx.app.R;
import com.sdkx.app.model.AirSpace;

public class AirSpaceOption extends Dialog implements View.OnClickListener {

    IOptionCallback iOptionCallback;
    public AirSpaceOption(@NonNull Context context) {
        super(context);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        View view  = getLayoutInflater().inflate(R.layout.airspace_create_option,null);
        setContentView(view);
        view.findViewById(R.id.roundspace).setOnClickListener(this);
        view.findViewById(R.id.polygonspace).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.roundspace:
                notify(AirSpace.TYPE_ROUND);
                break;
            case R.id.polygonspace:
                notify(AirSpace.TYPE_POLYGON);
                break;
        }
    }
    public interface IOptionCallback{
        void onCallback(int option);
    }
    private void notify(int option){
        if(iOptionCallback != null){
            iOptionCallback.onCallback(option);
        }
    }

    public void setiOptionCallback(IOptionCallback iOptionCallback) {
        this.iOptionCallback = iOptionCallback;
    }

}
